<?
/// --- AKCIÓ-VÉGREHAJTÁS ---

// FELHASZNÁLÓI AKCIÓK
switch($_GET['act']){
	case 'eat':
		$row = new DataRowManager('animals', (int)$_GET['id']);
		if($row->own()){
			$row->set('foodendtime', time()+$mainconf->get('foodtime'));
		}
		break;
	
	
}





///  --- OLDAL-ADATOK ELŐKÉSZÍTÉSE ---

// CONTENTS
//allatlista
	$a_list = new DataListManager('animals', 'userid='.$_SESSION['userid'], 'type');
	$i=0;
	if($a_list->length==0){
		$_output['noanimals']="{noanimals}<br><br><br>";
		$_output['noanimalslink']="{noanimalslink}<br>";
	}
	else{
		$_output['noanimals']="";
		$_output['noanimalslink']="";
	}
	while($curr = $a_list->next_row()){
		$val =  array();
		
		//row start/end
		if($i % 2 == 0){
			$val['rowstart']='<tr>';
			if($i==$a_list->length-1){ // utsó, de páratlan
				$val['rowend'] = '<td>&nbsp;</td></tr>';
			}
		}
		else{
			$val['rowend']='</tr>';
		}
		
		//id
		$val['id']=$curr->get('id');
		
		//name
		$val['name']= $curr->get('name');
		
		//type
		$val['type']= $curr->get('type');
		
		//etelszam
		$val['etelszam'] = $curr->get('foodtype');
		
		//image
		$val['image']='template/images/'.$curr->get('type').$curr->get('image').'.jpg';
		
		//happy
		$val['jokedv'] = round(calcHappy($curr));
		
		//food
		$etelnum = $curr->get('foodtype');
		$eteltext = "{etelnev".$etelnum."}"; //pl. {etelnev2}
		$val['etelnev'] = $eteltext;
		
		$foodendtime = $curr->get('foodendtime');
		if($foodendtime<=time()){
			$val['etelvege'] = "{elfogyott}";
		}
		else{

			$strdist = get_time_distance($foodendtime+60);
			$val['etelvege'] = "{lejar} ".make_date_text($strdist['minute'], $strdist['hour'], $strdist['day'], $strdist['week'])." {mulva}"; //azért kell a +1p mert pl. ha 0p y-mp van hátra akkor ne 0p-t hnem 1p-t írjon,
		}
		
		
		setContents('allatlista', $val);
		$i++;
	}
	

// OUTPUT




?>
